//
//  AuctionService.swift
//  LeGou
//
//  Created by lxm on 2022/10/15.
//

import Foundation
class AuctionService {
    private init(){}
    static let shared = AuctionService()
    
    func dateFromToday(_ interval : RxTimeInterval) -> Date {
        
        let now = Date(timeIntervalSince1970: RedBagService.shared.nowTimeinterval)
        if var d = now.zm.getTheDayStart() {
            d.addTimeInterval(transRxTimeIntervalToInterval(interval))
            return d
        } else {
            return Date()
        }
    }
    
    func transRxTimeIntervalToInterval(_ interval : RxTimeInterval) -> Double {
        var r : Int = 0
        switch interval {
        case .seconds(let t):
            r = t
        case .microseconds(let t):
            r = t / 1000_000
        case .nanoseconds(let t):
            r = t / 1000_000_000
        case .milliseconds(let t):
            r = t / 1000
        case .never:
            r = 0
        @unknown default:
            break
        }
        return Double(r)
    }
    
    // 生成通知ids
    func generateNotificationIdstr(_ id : Int, _ activityId : Int) -> String {
        return "\(id)-\(activityId)"
    }
}

